export function transform(data: any) {
  const nodes = data.nodes.map((item: any) => {
    const inPorts = item.inPorts.map((port: any) => {
      return {
        id: port.id,
        group: 'top',
      };
    });
    const outPorts = item.outPorts.map((port: any) => {
      return {
        id: port.id,
        group: 'bottom',
      };
    });
    return {
      id: item.id,
      shape: 'dag-node',
      x: item.positionX,
      y: item.positionY,
      data: {
        label: item.name,
      },
      ports: [...inPorts, ...outPorts],
    };
  });
  const links = data.links.map((link: any) => {
    return {
      id: link.id,
      shape: 'dag-edge',
      source: {
        cell: link.source,
        port: link.outputPortId,
      },
      target: {
        cell: link.target,
        port: link.inputPortId,
      },
    };
  });
  return [...nodes, ...links];
}
